<?php
defined('IN_ADMIN') or exit('No permission resources.'); 
$show_validator = $show_scroll = $show_dialog = 1; 
include $this->admin_tpl('header', 'admin');
 ?>
<form method="post" action="?m=<?php echo ROUTE_M;?>&c=<?php echo ROUTE_C;?>&a=<?php echo ROUTE_A;?>" id="myform">
<div class="pad-10">
<div class="col-tab">
	<ul class="tabBut cu-li">
		<li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',6,1);"><?php echo L('catgory_basic', '', 'admin');?></li>
		<li id="tab_setting_2" onclick="SwapTab('setting','on','',6,2);"><?php echo L('extend_setting')?></li>
	</ul>
<div id="div_setting_1" class="contentList pad-10">
	<table width="100%" class="table_form ">
		<tbody>
		<tr>
			<th width="200"><?php echo L('cn_name')?>：</th>
			<td><input name="goods[cn_name]" id="cn_name" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('en_name')?>：</th>
			<td><input name="goods[en_name]" id="en_name" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('original_price')?>：</th>
			<td><input name="goods[original_price]" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('preferential_price')?>：</th>
			<td><input name="goods[preferential_price]" id="preferential_price" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('goods_type')?>：</th>
			<td>
				<select name="goods[type]" >
				    <option value="0"><?php echo L('place_type')?></option>
					<?php echo $select_categorys;?>
				</select>
			</td>
		</tr>
		<tr>
			<th width="200"><?php echo L('place')?>：</th>

			<td><input name="goods[place]" id="place" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('factory')?>：</th>

			<td><input name="goods[factory]" id="factory" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('supplier')?>：</th>

			<td><input name="goods[supplier]" id="supplier" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th width="200"><?php echo L('goods_link')?>：</th>

			<td><input name="goods[goods_link]" id="goods_link" class="input-text" type="text" size="40"></td>
		</tr>
		<tr>
			<th><?php echo L('goods_description')?>：</th>
			<td><textarea name="goods[description]" id="description"></textarea>
							<?php echo form::editor('description','full','','','',1,1)?></td>
		</tr>
   		</tbody>
   </table>
</div>
<div id="div_setting_2" class="contentList pad-10 hidden">
	<table width="100%" class="table_form ">
		<tr>
			<th width="200"><?php echo L('image_horizontal_big')?>：</th>
			<td><?php echo form::images('goods[image_horizontal_big]', 'image_horizontal_big', '', 'goods', '', 40)?></td>
		</tr>
		<tr>
			<th><?php echo L('image_vertical_big')?>：</th>
			<td><?php echo form::images('goods[image_vertical_big]', 'image_vertical_big', '', 'goods', '', 40)?></td>
		</tr>
		<tr>
			<th><?php echo L('image_horizontal_small')?>：</th>
			<td><?php echo form::images('goods[image_horizontal_small]', 'image_horizontal_small', '', 'goods', '', 40)?></td>
		</tr>
		<tr>
			<th><?php echo L('image_vertical_small')?>：</th>
			<td><?php echo form::images('goods[image_vertical_small]', 'image_vertical_small', '', 'goods', '', 40)?></td>
		</tr>
		<tr>
			<th><?php echo L('image_square')?>：</th>
			<td><?php echo form::images('goods[image_square]', 'image_square', '', 'goods', '', 40)?></td>
		</tr>
   </table>
   </div>
	 <div class="bk15"></div>
    <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button">
</div></div>
</form>
</body>
</html>
<script type="text/javascript">
function load_file_list(id) {
	$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&module=special&templates=index|list|show&name=special', function(data){$('#index_template').html(data.index_template);$('#list_template').html(data.list_template);$('#show_template').html(data.show_template);});
}

function import_info(url, title, msgID, htmlID, valID) {
	window.top.art.dialog({id:'selectid',iframe:url, title:title, width:'600', height:'400', lock:true},
		function(){
			var d = window.top.art.dialog({id:'selectid'}).data.iframe;
			var form = d.document.getElementById(msgID);
			var text = form.value;
			var data = text.split('|');
			if (data[2]) {
				$('#'+htmlID).html('<ul id="relation_'+htmlID+'" class="list-dot"><li><span>'+data[2]+'</span><a onclick="remove_relation(\''+htmlID+'\', \''+valID+'\')" class="close" href="javascript:;"></a></li></ul>');
			} else {
				var dosubmit = d.document.getElementById('dosubmit');
				dosubmit.click();
				$('#'+htmlID).html('<ul id="relation_'+htmlID+'" class="list-dot"><li><span>'+text+'</span><a onclick="remove_relation(\''+htmlID+'\', \''+valID+'\')" class="close" href="javascript:;"></a></li></ul>');
			}
			$('#'+valID).val(text);
			window.top.art.dialog({id:'selectid'}).close();
			return false;
		},
		function(){
			window.top.art.dialog({id:'selectid'}).close();
		});void(0);
}

function remove_relation(htmlID, valID) {
	$('#relation_'+htmlID).html('');
	$('#'+valID).val('');
}

function addItem() {
	var n = $('#option_list').find('input[name]').length/3+1;
	var newOption =  '<div class="mb6"><span><?php echo L('type_name')?>：<input type="text" name="type['+n+'][name]" class="input-text" size="15">&nbsp;&nbsp;<?php echo L('type_path')?>：<input type="text" name="type['+n+'][typedir]" class="input-text" size="15">&nbsp;&nbsp;<?php echo L('listorder')?>：<input type="text" name="type['+n+'][listorder]" value="'+n+'" size="6" class="input-text" ></span>&nbsp;<a href="javascript:;" onclick="descItem(this, '+n+');"><?php echo L('remove')?></a></div>';
	$('#option_list').append(newOption);
}

function descItem(a, id) {
	$(a).parent().append('<input type="hidden" name="type['+id+'][del]" value="1">');
	$(a).parent().fadeOut();
}

function SwapTab(name,cls_show,cls_hide,cnt,cur){
	for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_'+name+'_'+i).show();
			 $('#tab_'+name+'_'+i).attr('class',cls_show);
		}else{
			 $('#div_'+name+'_'+i).hide();
			 $('#tab_'+name+'_'+i).attr('class',cls_hide);
		}
	}
}

$(document).ready(function(){
	$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'220',height:'70'}, function(){this.close();$(obj).focus();})}});
	$('#cn_name').formValidator({autotip:true,onshow:"<?php echo L('please_input_cn_name')?>",onfocus:"<?php echo L('please_input_cn_name')?>",oncorrect:"<?php echo L('true')?>"}).inputValidator({min:1,onerror:"<?php echo L('please_input_cn_name')?>"})
	
});
$("input:radio[name='special[ishtml]']").click(function (){
	if($("input:radio[name='special[ishtml]'][checked]").val()==0) {
		$("#file_div").hide();
	} else if($("input:radio[type='radio'][checked]").val()==1) {
		$("#file_div").show();
	}
});

$(function(){
	$('#classid').change(function(){
		var classid;
		classid = $(this).val();
		$.ajax({   
		    url:'?m=industrial&c=industrial&a=ajax_place_type&pc_hash='+pc_hash,   
		    type:'post',
		    dataType:"json",   
		    data:{'classid':classid},   
		    async : false, //默认为true 异步   
		    error:function(){   
		       alert('服务器异常');   
		    },   
		    success:function(data){
		    	var _html = '<option value="" >请选择</option>';
		    	var _htmls = '';
	    		$.each(data.classid,function(i,n) {     
			    	_html += '<option value="'+i+'" >'+n+'</option>';   
				});
				$.each(data.enterprise,function(i,n) {     
			    	_htmls += '<input type="checkbox" name="enterprise[]" id="enterprise_'+i+'" value="'+i+'">'+n;   
				});
		    	$("#place").html(_html); 
		    	$("#enterprise").html(_htmls);
		    }
		});
	})
	
})
</script>